home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Small Eiffel 0.4.8 / lib_rand / demo3.e < prev    next >
Text File  |  1997-04-13  |  1KB  |  55 lines

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class DEMO3
  5.  
  6. creation make 
  7.  
  8. feature
  9.  
  10.    make is
  11.       local
  12.      rand: GEN_RAND;
  13.      seed, count: INTEGER;
  14.       do
  15.      if argument_count < 2 then
  16.         io.put_string(
  17.         "Usage: demo <seed> <count> [min_stand|std_rand]%N%
  18.         %Examples :%N%
  19.         %   demo 234 10 %N%
  20.         %   demo 234 10 std_rand%N%
  21.         %   demo 234 100 min_stand%N");
  22.         die_with_code(exit_failure_code);
  23.      end;
  24.      seed := argument(1).to_integer;
  25.      count := argument(2).to_integer;
  26.      if argument_count > 2 then
  27.         if argument(3).same_as("MIN_STAND") then
  28.            !MIN_STAND!rand.with_seed(seed);
  29.            io.put_string("Using MIN_STAND%N.");
  30.         else
  31.            !STD_RAND!rand.with_seed(seed);
  32.            io.put_string("Using STD_RAND%N.");
  33.         end;
  34.      else
  35.         !STD_RAND!rand.with_seed(seed);
  36.         io.put_string("Using default STD_RAND%N.");
  37.      end;
  38.      from
  39.      until
  40.         count = 0
  41.      loop
  42.         rand.next;
  43.         io.put_double(rand.last_double);
  44.         count := count - 1;
  45.         io.put_string("%N");
  46.      end;
  47.       end;
  48.  
  49.    generators: ARRAY[STRING] is 
  50.       once
  51.      Result := <<"MIN_STAND","STD_RAN">>;
  52.       end;
  53.  
  54. end -- DEMO3
  55.